package com.songshuai.webapi.baseapi.enumerations.sales;

public enum SopStatusEnum {
    Https(0,"https://"),
    Default(123456, "默认redisKey"),
    Del(1, "删除"),
    UnDel(0, "未删除"),
    Article(8133001, "文章"),
    Video(8133002, "视频"),
    Publish(1, "已发布"),
    UnPublish(0, "未发布"),
    DelayedPublish(-1, "延迟发布"),
    Publish_(0, "publish_"),
    Top(1, "置顶"),
    Top_(0, "top_"),
    UnTop(0, "取消置顶"),
    PrefixTop(0, "tools:top_"),
    PrefixPublish(0, "tools:publish_"),
    Up(1, "上架"),
    UnUp(0, "下架"),
    SopAddSopStatus(0, "sop添加状态");


    private int code;
    private String msg;

    SopStatusEnum(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return SopStatusEnum.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return SopStatusEnum.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(SopStatusEnum err : SopStatusEnum.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
